package com.stream;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Test04 {
    public static void main(String[] args) {

        List<Integer> integerList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

        List<Integer> removeList = Arrays.asList(5, 6, 7);

        // 比较差值,将数据为null值的排在最后
        List<Integer> newList = integerList.stream()
                .filter(item -> !removeList.contains(item))
                .sorted(Comparator.comparing(item -> item, Comparator.nullsLast(Integer::compareTo)))
                .collect(Collectors.toList());

        if (newList.size() > 0) {
            for (Integer integer : newList) {
                System.out.println(integer);
            }
        }
    }
}
